Conversation
…ookies When a headless session acquires Google login cookies and writes them to the persistent profile, needsSync() was returning true after 30 minutes (or when the real Chrome Cookies file changed), causing syncProfileData() to overwrite those cookies with the real Chrome profile's cookies. Add a guard that checks the persistent profile's Cookies mtime against the last sync timestamp. If the persistent Cookies were modified after the last sync, a headless session must have written them — skip the overwrite to preserve the acquired session (Root Cause B, issue #606). Co-Authored-By: Claude Sonnet 4.6 <noreply@anthropic.com>
34 tasks
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
Summary
Fixes #606 (Root Cause B): when a headless session acquires Google login cookies and writes them to
~/.openchrome/profile/Default/Cookies, the next launch incorrectly overwrites those cookies by syncing from the real Chrome profile.Root cause:
needsSync()returnstruewhen the last sync is older than 30 minutes or the source Cookies file has changed — with no awareness that a headless session may have written newer cookies into the persistent profile in the meantime.Fix: Before returning
truefor staleness or source-hash mismatch, check whether the persistent profile'sCookiesfile has a newermtimethan thelastSyncTimestamp. If so, a headless session wrote cookies after the last sync — skip the overwrite.Changes
src/chrome/profile-manager.ts: Added guard inneedsSync()that compares persistent profile CookiesmtimeagainstlastSyncTimestamp. Returnsfalse(skip sync) when persistent cookies are newer, preserving headless-acquired session.tests/chrome/persistent-profile.test.ts: Added test caseshould return false when persistent profile Cookies were modified after last sync (headless guard)covering the new guard path. All 48 tests pass.Test plan
needsSync()returnsfalsetrue, stale →true, fresh+unchanged →false, no metadata →true, no source Cookies →falsenpm run buildpasses with zero errorsnpx jest tests/chrome/persistent-profile.test.ts— 48/48 passed🤖 Generated with Claude Code